﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using MetaSharp.Transformation.Properties;
using System.Threading.Tasks;

namespace MetaSharp.Transformation.Tests.Patterns
{
	public class DefaultTests
	{
		[Fact]
		public async Task ReadsEmptyInput()
		{
            var p = Pattern.Default();
            var m = await Pattern.Match(p, "");
			Assert.True(m.Matched);
		}

		[Fact]
		public async Task ReadsNoInput()
        {
            var p = Pattern.Default();
            var m = await Pattern.Match(p, "a");
            Assert.Equal('a', m.End.Stream.Next().Current);
		}

		[Fact]
		public async Task ReadsNoInputButProjects()
		{
			var p = Pattern.And(
				Pattern.Any(),
				Pattern.Default(),
				Pattern.Any());
            var m = await Pattern.Match(p, "ab");
            Assert.Equal(new object[] { 'a', null, 'b' }, m.Value);
		}
	}
}
